package com.example.weektwo.dailysupplies.one;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.weektwo.Bean.ContentDatas;
import com.example.weektwo.Bean.InfoBean;
import com.example.weektwo.R;
import com.example.weektwo.dailysupplies.two.ChoiceActivity;

import java.io.Serializable;
import java.util.List;

public class DailyActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = "DailyActivity";
    List<String> kindList;
    ListView dailyList;
    private DailyShopAdapter adapter;
    TextView tv_title;
    ImageView iv_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_daily);
        kindList = ContentDatas.getDailyKindList();
        String s = kindList.get(3);
        Log.d(TAG, "s: " + s);
        dailyList = findViewById(R.id.daily_list);
        tv_title = findViewById(R.id.top_tv);
        iv_back = findViewById(R.id.top_iv);
        adapter = new DailyShopAdapter(this, kindList);
        tv_title.setText("日常用品");
        dailyList.setAdapter(adapter);
        iv_back.setOnClickListener(this);
        dailyList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent();
                String kindname = kindList.get(position);
                intent.setClass(DailyActivity.this, ChoiceActivity.class);
                intent.putExtra("name",kindname);
                intent.putExtra("pos",position);
                startActivity(intent);


                startActivity(intent);
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.top_iv:
                finish();
                break;
        }
    }
}
